<script>
	$(function(){

        // 载入页面后立马请求默认节点的数据
        layui.use('common', function() {
            var common = layui.common;
            var url = "<{:U('Section/dispatch')}>";
            var param = {
				"aid": $(":hidden[name='aid']").val(),
				"nid": <{$vehicle.nid}>
			};
            common.ajaxSubmit(url, param, function(res){
                $("#ajax_content").html(res || "nothing is found...");
            });
        });

		// 点击按钮进入对比模式
		$("button[name='compare']").click(function(event) {
			// 对比模式
			var c = $(this).attr("compared");
			var compared = 0;
			if(c==1){// 如果选中则取消
				compared = 0;
				$(this).html("<i class='icon icon-document'></i>Compare");
				var url = "<{:U($module.'/dispatch')}>";
			} else {// 否则就选中
				compared = 1;
				$(this).html("<i class='icon icon-document'></i>Cancel compare");
				var url = "<{:U($module.'/compare')}>";
			}			
			$(this).attr("compared", compared);
			// 当前节点
			var treeObj = $.fn.zTree.getZTreeObj("option_tree");
			var nodes = treeObj.getSelectedNodes();
			var nid = nodes!=false? nodes[0].id : 0;
			// 获取数据
			var param = {"aid": $(":hidden[name='aid']").val(), "nid":nid};
			$.getJSON(url, param, function(res){
				!res || $("#ajax_content").html(res.data);
			});
		}); 

		// 标题栏显示/隐藏效果
		$("#ajax_content").delegate('.slideBtn', 'click', function() {
	        var controlDIV = $(this).next();
	        if (controlDIV.is(":hidden")) {
	            controlDIV.slideDown("slow");
	            $(this).find("i").removeClass("icon-down").addClass("icon-up");
	        } else{
	            controlDIV.slideUp("slow");
	            $(this).find("i").removeClass("icon-up").addClass("icon-down");
	        }
	    });

	})
</script>

<!-- 当前位置 -->
<div class="breadCrumbs"><i class="icon icon-home"></i><a href="<{:U($module.'/index')}>"><{$module}></a>&gt;<span><{$vehicle.brand}></span></div>

<!-- 当前车型概要 -->
<div class="performanceDteial">
	<div class="thumb"><img src="<{$vehicle.url}>" alt=""></div>
	<div class="tbInfo">
		<table class="tb_carInfo">
			<tr>
				<th>Vehicle</th>
				<td><{$vehicle.brand}></td>
			</tr>
			<tr>
				<th>Model Year</th>
				<td><{$vehicle.year}></td>
			</tr>
			<tr>
				<th>Engine Volume/L</th>
				<td><{$vehicle.engine}></td>
			</tr>
			<tr>
				<th>Number of graphs</th>
				<td><{$vehicle.quantity}></td>
			</tr>
		</table>
	</div>

	<div class="mainRight">
		<button class="layui-btn layui-btn-small" name="compare" compared="0"><i class="icon icon-document"></i>Compare</button>
	    <button class="layui-btn layui-btn-normal layui-btn-small"><i class="icon icon-favorite"></i>Add Favorite</button>
	    <button class="layui-btn layui-btn-warm layui-btn-small layui-btn-report"><i class="icon icon-report"></i>Report</button>
	    <button class="layui-btn layui-btn-danger layui-btn-small"><i class="icon icon-scanning"></i>Scanning Part</button>
	</div>

	<div class="clearfix"></div>
</div>

<!-- 数据区域 -->
<div id="ajax_content" class="conbox"></div>